let db = require('../db/index')
exports.getAside = (req, res) => {
    let sql = 'select * from aside'
    db.query(sql, (err, data) => {
        if(err) {
            return res.send('错误：' + err.message)
        }
        console.log(data);
        let config = JSON.parse(JSON.parse(data[0].config))
        let result ={
            id :data[0],
            config : config.config,
        }
            let resultRes = {
                data : result,
                status : 200,
                message : 'success',
            }
        res.send(resultRes)
    })
}
exports.addAside = (req, res) => {       
    let sql = 'insert into aside (config) values (?)'
    let data = JSON.stringify(req.query.config)
    db.query(sql, [data], (err, data) => {
        if(err) {
            return res.send('错误：' + err.message)
        }
        let result = {
            data :{
                status : 200,
                message : 'success', 
            }
        }
        res.send(result)
    })
}

